package com.jqb.sturts2lab02.action;

import com.opensymphony.xwork2.ActionSupport;

public class JsonPluginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private int id;
	private String name;
	private String address;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	/**
	 * 可以通过JSON注解配置属性-改名(注解必须写在方法前而不是属性前)
	 */
	/*@JSON(name="userName")*/
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}

	@Override
	public String execute() throws Exception {
		if (this.name.equals("Tom")) {
			id = 1005;
			address = "Shanxi";
		} else if (this.name.equals("Jerry")) {
			id = 1006;
			address = "Xinjiang";
		}
		return SUCCESS;
	}
	
}
